package eg.edu.eelu.fyp2013.jdetector.core.Enhancement;

import java.awt.Image;
import java.awt.image.BufferedImage;
import java.util.ArrayList;

import eg.edu.eelu.fyp2013.jdetector.core.filters.impl.MedianFilter;
import eg.edu.eelu.fyp2013.jdetector.core.input_output.AMatrix;
import eg.edu.eelu.fyp2013.jdetector.gui.MRI_Brain_Tumor_Classification_Tool;
public class Enhance {
	
	public ArrayList<AMatrix> ApplyEnhance (ArrayList<AMatrix> Alllearn)
	{
		
		ArrayList<AMatrix> MedianEnc = new ArrayList<AMatrix>();
		for(int i = 0 ; i < Alllearn.size(); i++)
		{
			AMatrix Med = new AMatrix();
			int filterWidth=7;
			int filterHeight=7;
			MedianFilter medianFilter = new MedianFilter(filterWidth,filterHeight);
					
			Image filteredImage = medianFilter.applyFilter(Alllearn.get(i).GetImage);
			BufferedImage MedfilterdImage = (BufferedImage) filteredImage;
			
	
			for(int j = 0; j < MedfilterdImage.getWidth(); j++)
			{
				for(int k = 0; k < MedfilterdImage.getHeight(); k++)
				{
					Alllearn.get(i).matrix[j][k] = MedfilterdImage.getRGB(j, k);
				}
			}
					
			Med.matrix = Alllearn.get(i).matrix;
			Med.label = Alllearn.get(i).label;
			Med.height = Alllearn.get(i).height;
			Med.width = Alllearn.get(i).width;
			Med.GetImage = (BufferedImage) filteredImage;
					
			MedianEnc.add(Med);
			
		}
		return MedianEnc;
		
	}

}
